package com.qd.common.sys.domain.entity.role;

import com.cdqidi.valid.group.DefaultGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

@Data
@Accessors(chain = true)
@EqualsAndHashCode
public class RolePersonRelationsDTO {

    /**
     * 角色ID
     */
    @NotBlank(message = "角色ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "角色ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String roleId;

    /**
     * 角色对应的人员信息
     */
    @Valid
    @NotNull(message = "人员信息不能为空", groups = DefaultGroup.class)
    private List<String> personList;

    public void freeData() {
        this.roleId = null;
        if (null != personList) {
            personList.clear();
            personList = null;
        }
    }
}
